package com.example.yls.demoa;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class MyBroadcastReceiver extends BroadcastReceiver{

    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();

        if (action.equals("Weather_Report")) {
            String weather = intent.getStringExtra("weather");
            int temp = intent.getIntExtra("temprature", 0);
            Log.e("MyBroadcastReceiver",
                    "收到天气广播，天气" + weather
                            + "温度" + temp);
        }
        else if (action.equals("Trafic_Report")) {
            String trafic = intent.getStringExtra("Trafic");
            int time = intent.getIntExtra("Time", 0);
            Log.e("MyBroadcastReceiver",
                    "收到交通广播，交通" + trafic
                            + "时间" + time);
        }
    }
}

